package org.ms.mconf.sdk.model;

import lombok.*;

import java.io.Serializable;
import java.util.List;

/**
 * The Meta Data Entry Model
 *
 * @author lry
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class MetaMultiDataConfig implements Serializable {

    /**
     * The Meta Config Entry
     */
    private MetaConfig meta;

    /**
     * The Data Config Entry
     */
    private List<DataConfig> data;

    /**
     * The build Meta Multi Data Config
     *
     * @param channel channel name
     * @param message message data
     * @return {@link MetaMultiDataConfig}
     */
    public static MetaMultiDataConfig parseMetaMultiDataConfig(String channel, String message) {
        MetaMultiDataConfig metaMultiDataConfig = new MetaMultiDataConfig();

        MetaConfig metaConfig = MetaConfig.parseChannel(channel);
        metaMultiDataConfig.setMeta(metaConfig);

        List<DataConfig> dataConfigs = DataConfig.parseMessage(message);
        metaMultiDataConfig.setData(dataConfigs);

        return metaMultiDataConfig;
    }

}